using System.Collections.Generic;
using System.Linq;
using System;
using System.Windows.Forms;

using SolutionOrchestrator.Properties;

namespace SolutionOrchestrator
{
	class MySettingsProviderImpl : ObservableObject, IMySettingsProvider
	{
		MySettings _mySettings;

		public MySettings Get
		{
			get { return _mySettings ?? (_mySettings = Load()); }
		}

		public IList<string> RootPathCollection
		{
			get { return Get.RootPathCollection; }
		}

		public string CurrentRootPath
		{
			get { return Get.CurrentRootPath; }
			set { Get.CurrentRootPath = value; }
		}

		MySettings Load()
		{
			var serialized = Settings.Default.MySettings;
			var result = XamlHelper.ParseXaml<MySettings>(serialized);
			result.PropertyChanged += SettingsPropertyChanged;
			return result;
		}

		void SettingsPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
		{
			OnPropertyChanged(e.PropertyName);
		}

	}
}